﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharedGenomics.Workbench.Core
{
    public class BackgroundOperationResult
    {
        public BackgroundOperationResult()
        {
        }

        public BackgroundOperationResult(Exception error)
        {
            this.Error = error;
        }

        public Exception Error { get; private set; }
    }

    public class BackgroundOperationResult<T> : BackgroundOperationResult
    {
        private T _result;
        public BackgroundOperationResult(T result)
        {
            this.Result = result;
        }

        public BackgroundOperationResult(Exception error)
            : base(error)
        {
        }

        public T Result
        {
            get
            {
                if (this.Error == null)
                    return this._result;
                else
                    throw this.Error;
            }
            private set
            {
                this._result = value;
            }
        }
    }
}
